package Controller;


import javax.persistence.EntityManager;
import javax.persistence.Persistence;
import javax.persistence.Query;

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author MTI
 */
public class LastID {
    public int LastID(String tablename)
    {
        EntityManager entityManager =  Persistence.createEntityManagerFactory("KitapcdappPU").createEntityManager();
        Query query = entityManager.createNamedQuery(tablename+".findLastId");
        query.setMaxResults(1);
        int i;
        i = (Integer)query.getSingleResult();
        i++;
        return i;
    }
}
